package com.neusoft.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.neusoft.mapper.base.Borrow_historyMapper;
import com.neusoft.model.entity.Books;
import com.neusoft.model.entity.BooksExample;
import com.neusoft.model.entity.Borrow_history;
import com.neusoft.model.entity.Borrow_historyExample;
import com.neusoft.service.BorrowHistoryService;


@Service
public class BorrowHistoryServicelmpl implements BorrowHistoryService{
	@Autowired
	Borrow_historyMapper borrow_historymapper;

	// 通过用户ID查看借阅历史
	@Override
	public List<Borrow_history> borrow_history(String id) {
		Borrow_historyExample bor_exam = new Borrow_historyExample();
		Borrow_historyExample.Criteria example = bor_exam.createCriteria();
		example.andIdEqualTo(id);

		List<Borrow_history> history_list = new ArrayList<Borrow_history>();
		System.out.println(borrow_historymapper.selectByExample(bor_exam)
				.size());
		history_list = borrow_historymapper.selectByExample(bor_exam);
		System.out.println("serviceserviceserviceserviceservice");
		return history_list;

	}

	@Override
	public int countBorrowhistory() {
		List<Borrow_history> borrow_histories=new ArrayList<Borrow_history>();
		Borrow_historyExample borrow_historyExample=new Borrow_historyExample();
		borrow_histories=borrow_historymapper.selectByExample(borrow_historyExample);
		return borrow_histories.size();
		
	}
}
